<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件对象</title>
</head>

<body>
  <button>按钮</button>
  <input type="text">
  <script>
    const btn = document.querySelector('button')
    const ipt = document.querySelector('input')
    btn.addEventListener('click', function (e) {
      console.log(e);
      // 获取事件的类型
      console.log(e.type);
    })

    ipt.addEventListener('keyup', function (e) {
      console.log(e);
      // 获取键盘的键的值
      console.log(e.key);
    })
  </script>
</body>

</html>